package ThreadDemo;

import java.util.Scanner;

public class ThreadDemo9 {
    static class  wsw{
       volatile int flog=0;
    }
    public static void main(String[] args) {
         wsw wsw=new wsw();
        Thread thread1=new Thread(new Runnable() {
            @Override
            public void run() {
                while (wsw.flog==0){
//                    try {
//                        Thread.sleep(500);
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                    System.out.println("线程1");
                }
                System.out.println("循环结束");
            }
        });
        Thread thread2=new Thread(new Runnable() {
            @Override
            public void run() {

                System.out.println("请输入");
                Scanner scanner=new Scanner(System.in);
                wsw.flog=scanner.nextInt();
            }
        });
        thread1.start();
        thread2.start();
    }
}
